package com.xc.hellofx;

import cn.hutool.http.HttpUtil;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

public class HelloController {
    @FXML
    private Label result;

    @FXML
    private TextField website;

    @FXML
    protected void onHelloButtonClick() {
        String url = "https://www.qqlykm.cn/api/who/?domain=";
        Platform.runLater(()->{
            String input = website.getText();
            String info = HttpUtil.get(url + input);
            try {
                Thread.sleep(1000);
            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
            int pre1 = info.indexOf("<pre>") + 6,pre2 = info.indexOf("URL of the ICANN Whois",pre1);
            String pre = info.substring(pre1,pre2);
            result.setText(pre);
        });
    }
}